var i;
Object.defineProperty(exports, "__esModule", {
  value: true
});
var EventManager = require("AA_EventManager");
var ResKeeper = require("AA_ResKeeper");
var CommonUtils = require("AA_CommonUtils");
var EvenType = require("AA_EvenType");
var NodePoolMag = require("AA_NodePoolMag");
var UI_AttackInfo = require("AA_UI_AttackInfo");
var _decorator = cc._decorator;
var _ccclass = _decorator.ccclass;
var _property = _decorator.property;

var _def_UI_ShowAttackInfo = function (e) {
  function _creator() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.item = null;
    return t;
  }
  __extends(_creator, e);
  _creator.prototype.addEvent = function () {
    EventManager.EventMgr.addEventListener(EvenType.EVENT_TYPE.Game_ShangHai_FeiZi, this.onPiaoZi, this);
  };
  _creator.prototype.rmEvent = function () {
    EventManager.EventMgr.rmEventListener(EvenType.EVENT_TYPE.Game_ShangHai_FeiZi, this.onPiaoZi, this);
  };
  _creator.prototype.onPiaoZi = function (e, t, o, n) {
    undefined === n && (n = 1);
    var i = NodePoolMag.NodePoolMag.instance.getNode("piaozi");
    if (!i) {
      NodePoolMag.NodePoolMag.instance.createNodeCount("piaozi", 1, this.item);
      i = NodePoolMag.NodePoolMag.instance.getNode("piaozi");
    }
    i.stopAllActions();
    if (o) {
      var a = CommonUtils.default.limitInteger(0, o.width / 2);
      Math.random() > .5 && (a = -a);
      t.x = a;
      t.y = 0;
      o.addChild(i);
      switch (n) {
        case 2:
          i.zIndex = 1;
          break;
        case 4:
          i.zIndex = 2;
          break;
        default:
          i.zIndex = 0;
      }
    } else {
      t = this.node.convertToNodeSpaceAR(t);
      t = this.generateRandomPoint(t, 50);
      this.node.addChild(i);
      i.zIndex = 2 == n ? 1 : 0;
    }
    i.getComponent(UI_AttackInfo.default).setValue(e, n);
    i.x = t.x;
    i.y = t.y + 80;
    i.opacity = 255;
    cc.tween(i).to(.1, {
      scale: 1.5
    }).to(.3, {
      scale: 1
    }).call(function () {}).start();
    cc.tween(i).to(.1, {
      y: i.y + 100
    }).to(.3, {
      y: i.y + 120
    }).delay(.1).to(.05, {
      opacity: 0
    }).call(function () {
      NodePoolMag.NodePoolMag.instance.recycleNode("piaozi", i);
    }).start();
  };
  _creator.prototype.generateRandomPoint = function (e, t) {
    var o = 2 * Math.random() * Math.PI;
    var n = Math.random() * t;
    return e.add(new cc.Vec2(Math.cos(o) * n, Math.sin(o) * n));
  };
  __decorate([_property(cc.Prefab)], _creator.prototype, "item", undefined);
  return __decorate([_ccclass], _creator);
}(ResKeeper.default);
exports.default = _def_UI_ShowAttackInfo;